---@class SelectSkillActionBak:AbstractLeaf
local SelectSkillActionBak = ClientFight.CreateClass("SelectSkillActionBak",ClientFight.AbstractLeaf,ClientFight.IAction)

---@return EStatus
function SelectSkillActionBak:update()
   SkillRoleMgr.savePathFile( "[" ..self.fight.frame.."][技能选择]"..self.fighter:print() .. "进行技能选择")
    --不能使用技能或者被魅惑
    if FighterStateEnum.is(self.fighter,FighterStateEnum.CAN_NOT_USE_SKILL) or FighterStateEnum.is(self.fighter,FighterStateEnum.CHARM) then
       SkillRoleMgr.savePathFile("[" ..self.fight.frame .."][技能选择]" ..self.fighter:print() .."因为不能使用技能而选择普通攻击")
        -- 进行普通攻击
        return self:selectNormalAttack()
    end
    for k ,skill in pairs(self.fighter.skills) do
        --冷却中
        if not SkillManager.isCooldowning(self.fighter, skill.skillId) and self.fighter.energy >= self.fighter:calUseSp(skill) then
            local target = SkillManager.selectAttackTarget(self.fight, self.fighter, skill, self.fighter.position, nil, false)
            if target then
               SkillRoleMgr.savePathFile( "[" ..self.fight.frame .. "][技能选择]" ..self.fighter:print() .."进行选择技能："
                     .. skill.skillBean.f_SkillID)
                self.fighter:setPrepareSkill(skill)
                self.fighter.prepareTarget = target
                return EStatus.SUCCESS
            end
        end
    end
    return self:selectNormalAttack()
end
function SelectSkillActionBak:selectNormalAttack()
    if SkillManager.isCooldowning(self.fighter, self.fighter.normalAttack.skillId) then
       SkillRoleMgr.savePathFile("["..self.fight.frame .."][技能选择]" ..self.fighter:print().."因为普通攻击冷却中而选择失败")
        return EStatus.FAILURE
    else
        local target = SkillManager.selectAttackTarget(self.fight, self.fighter, self.fighter.normalAttack, self.fighter.position, nil, false)
        if target then
           SkillRoleMgr.savePathFile( "[" .. self.fight.frame.. "][技能选择]".. self.fighter:print() .."进行选择技能(普攻)："
                   ..self.fighter.normalAttack.skillBean.f_SkillID)
            --进行普通攻击
            self.fighter:setPrepareSkill(self.fighter.normalAttack)
            self.fighter.prepareTarget = target
            return EStatus.SUCCESS
        end
    end
    return EStatus.FAILURE
end